//
//  HomeSegmentViewModel.swift
//  ManBetX
//
//  Created by Cocoa on 2020/4/28.
//  Copyright © 2020 Fullen. All rights reserved.
//

import UIKit

class HomeSegmentViewModel: BaseViewModel {
    
    var dataDic: [String: Any] = NSDictionary.init() as! [String : Any]// 当前VM的数据源
    var isFirstItemAllAllLine: Bool = false// 决定当前 VM 返回的Size -- 外部赋值
    var isUnderMaintenance: Bool = false// 游戏是否在维护中 -- 外部赋值
    var gameTitle: String = ""// 游戏标题
    var imgNameIOS: String = ""// 图片URL
    var gameId: String = ""// 游戏Id
    
    override func create() {
        
        if self.entity is [String: Any] {
            self.dataDic = entity as! [String : Any]
            self.imgNameIOS = self.dataDic["imgNameIOS"] as! String
            self.gameTitle = self.dataDic["name"] as? String ?? ""
            self.gameId = self.dataDic["id"] as? String ?? ""
        }
    }
    
    override func cellSize() -> CGSize {
        let homeItemWidth: CGFloat = kScreenWidth
        let homeItemHeight: CGFloat = 148.0
        if self.isFirstItemAllAllLine {
            // 单行展示
            return CGSize.init(width: homeItemWidth, height: homeItemHeight)
        }
        // 多行展示
        return CGSize.init(width: homeItemWidth/2, height: homeItemHeight)
    }
}
